<html>

<head>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" charset="utf-8">
    <title>demo 网页</title>
    <script type="text/javascript">
        function hello(str) {
            alert(str);
            return "excute done";
        }
        function abc() {
            alert("dsfsdf");
            document.getElementById("demo").innerHTML = "hahha";
        }

        function chatClick() {
            window.location.href = "com.taylor.custom://a=123&b=456";
        }

        function fromOC(str) {

        }

        function show_prompt() {
            var value = prompt('输入你的名字：', '默认名字');
            if (value == null) {
                alert('你取消了输入！');
            } else if (value == '') {
                alert('姓名输入为空，请重新输入！');
                show_prompt();
            } else {
                alert('你好，' + value);
            }
        }

        function sendmessageToWebKit() {
            try {
                window.webkit.messageHandlers.oc.postMessage({ "data": "haha" });
            } catch (expection) {
                console.log('sendmessageToWebKit failed');
            }
        }

        function calliOSMethods() {
            // 调用 原生程序通过JSContext注入进来的对象中的方法
            try {
                var result = jsexport.sendMsssageToJS('执行原生代码');
                document.getElementById("demo").innerHTML = result;
            } catch (error) {
                console.log(error);
            }
        }
        /*
        function jsexport(name, desc) {
            // this.name = name;
            // this.desc = desc;
            // this.sendMsssageToJS = function(str){};
            // this.receivedMessageFromJS = function(str){};
        }
        */


    </script>
</head>

<body>
    <p>大家好，我是taylor dong，欢迎光临!</p>
    <p id="demo">这是第二段</p>
    <p id="demo2">使用WebKit更改值</p>
    <button onclick="abc()">点我</button>
    <button onclick="chatClick()">和我聊天</button>
    <button onclick="show_prompt()">输入框</button>
    <button onclick="sendmessageToWebKit()">发送数据到WebKit</button>
    <button onclick="calliOSMethods()">调用原生方法</button>
    
   
</body>

</html>
